//
//  GHAboutUsViewController.m
//  GodHorses
//
//  Created by Mac on 2017/11/16.
//  Copyright © 2017年 stoneobs@icloud.com. All rights reserved.
//

#import "GHAboutUsViewController.h"

@interface GHAboutUsViewController ()
@property(nonatomic, strong) NSArray<GHTableEasyModel*>                     *datasouce;
@end

@implementation GHAboutUsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"关于我们";
    self.tableView.scrollEnabled = NO;
    [self configSubView];
    self.datasouce = @[
                       [[GHTableEasyModel alloc] initWithTextString:@"微信公众号" detailString:@"神马泉"],
                       [[GHTableEasyModel alloc] initWithTextString:@"QQ" detailString:@"1101989540"],
                       [[GHTableEasyModel alloc] initWithTextString:@"官方网站" detailString:@"http://www.smqyp.com"]
                       ];
    // Do any additional setup after loading the view.
}
#pragma mark --subView
- (void)configSubView{
    UIView * header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, 190)];
    header.backgroundColor = self.tableView.backgroundColor;
    
    UIImageView * logImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 35, 80, 80)];
    logImageView.clipsToBounds = YES;
    logImageView.layer.cornerRadius = 5;
    logImageView.st_centerX = UIScreenWidth / 2;
    logImageView.image = [UIImage imageNamed:@"logo"];
//    logImageView.backgroundColor = [UIColor colorWithRed:55/255.0 green:60/255.0 blue:156/255.0 alpha:1];
    [header addSubview:logImageView];
    
    STLabel * titleLable = [[STLabel alloc] initWithFrame:CGRectMake(0, logImageView.st_bottom + 5, UIScreenWidth, 18)
                                                     text:@"神马泉"
                                                textColor:GH_firstTextColor
                                                     font:15
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentCenter];
    titleLable.st_centerX = UIScreenWidth / 2;
    [header addSubview:titleLable];
    self.tableView.tableHeaderView = header;
    
    //copyRight
    STLabel * commpanyLable = [[STLabel alloc] initWithFrame:CGRectMake(15, 0, UIScreenWidth - 30, 13)
                                                     text:@"四川神马泉电子商务有限公司"
                                                textColor:GH_firstTextColor
                                                     font:12
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentCenter];
    commpanyLable.st_centerX = UIScreenWidth / 2;
    [self.view addSubview:commpanyLable];
    STLabel * copyLable = [[STLabel alloc] initWithFrame:CGRectMake(15, 0, UIScreenWidth - 30, 13)
                                                        text:@"Sichuan shenmaquan electronic business limited"
                                                   textColor:GH_firstTextColor
                                                        font:12
                                                 isSizetoFit:NO
                                               textAlignment:NSTextAlignmentCenter];
    copyLable.st_centerX = UIScreenWidth / 2;
    copyLable.st_bottom = UIScreenHeight - 20 - 64;
    commpanyLable.st_bottom = copyLable.st_top - 5;
    [self.view addSubview:copyLable];
}
#pragma --mark UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return self.datasouce.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 44;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    
    return 0.01;
}
- (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    return [UIView new];
}
- (UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    return [UIView new];
}
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString * reuseIdentifier =  @"cell";
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuseIdentifier];
        
    }
    cell.textLabel.textColor = UIColorFromRGBA(0x333333);
    cell.textLabel.font = [UIFont systemFontOfSize:14];
    cell.detailTextLabel.font = [UIFont systemFontOfSize:13];
    cell.detailTextLabel.textColor = UIColorFromRGBA(0x999999);
    GHTableEasyModel * mdoel = self.datasouce[indexPath.row];
    cell.textLabel.text = mdoel.textString;
    cell.detailTextLabel.text = mdoel.detailString;
    return cell;
}
#pragma --mark UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.row == 2) {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.smqyp.com"]];
    }
    [self.tableView deselectRowAtIndexPath:indexPath animated:NO];
}


@end
